<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/16
 * Time: 11:15
 */

include_once '../tools/DbTools.php';


$accountCode = $_POST['AccountCode'];
$cardNo = $_POST['CardNo'];
$password = $_POST['password'];
$money = $_POST['money'];

DbTools::InitDb();
//查询是否存在账户
$sql_account = "select * from AccountInfo where AccountCode = $accountCode";
$result = DbTools::select($sql_account);
if (empty($result)){
    echo '该账户不存在'.'<a href="originalPage.php">回到操作页面</a>&nbsp;&nbsp;&nbsp;<a href="createAccount.php">创建账户</a>';
    die;
}
else{
    $accountId = $result[0]['AccountId'];
    $sql_createcard = "insert into bankcard(CardNo,AccountId,CardPwd,CardMoney,CardState,CardTime)
            values ($cardNo,$accountId,$password,$money,1,NOW())";
    $result_create = DbTools::noSelect($sql_createcard);
    print_r($result_create);
}